<template>
    <div class="orientation">
        <div class="orientation_tit">
            <NavBar :tit="'筛选'"></NavBar>
        </div>
        <div class="orientation_houseCont">
            <HouseCont></HouseCont>
        </div>
        <div class="orientation_type">
            <div class="verify_type">
                <h3>验真情况</h3>
                <div class="verify_select_type">
                    <p :class="buyHouse.currentIndex === ind ? 'active' : '' " v-for="(k,ind) in buyHouse.houseSelect" :key="ind"  @click="selectTag(k,ind)" >{{k.title}}</p>
                </div>
            </div>

            <div class="buyHouse_orientation">
                <h3>朝向</h3>
                <div class="buyHouse_select_orientation">
                    <p :class="buyHouse.roomIndex === i ? 'roomActive' : '' " v-for="(v,i) in buyHouse.houseType" :key="i" @click="roomSelect(v,i)">{{v.title}}</p>
                </div>
            </div>

            <div class="buyHouse_condition">
                <h3>住房条件</h3>
                <div class="buyHouse_select_condition">
                    <p :class="buyHouse.conditionIndex === index ? 'roomActive' : '' " v-for="(z,index) in buyHouse.houseCondition" :key="index" @click="conditionSelect(z,index)">{{z.title}}</p>
                </div>
            </div>
        </div>
        <div class="orientation_Sure">
            <HouseSure :tit="'筛选'" @cancelBtn="cancelDatum" :selectProps="selectDatum"></HouseSure>
        </div>
    </div>
</template>

<script>
import { defineComponent , reactive , ref , onMounted} from 'vue'
export default defineComponent({
  setup(props,context) {
    const buyHouse = reactive({
            houseSelect:[
                {
                    'title':'不限'
                },
                {
                    'title':'安选'
                },
            ],
            houseType:[
                {
                    'title':'东'
                },
                {
                    'title':'南'
                },
                {
                    'title':'西'
                },
                {
                    'title':'北'
                },
                {
                    'title':'南北'
                },
            ],
            houseCondition:[
                {
                    'title':'邻地铁'
                },
                {
                    'title':'押一付一'
                },
                {
                    'title':'配套齐全'
                },
                {
                    'title':'可短租'
                },
                {
                    'title':'女生合租'
                },
                {
                    'title':'男生合租'
                },
                {
                    'title':'独立卫生间'
                },
                {
                    'title':'独立阳台'
                },
            ],
            currentIndex:'',
            roomIndex:'',
            conditionIndex:'',
        })
        
        // 选择的值
        const selectDatum = reactive({
            verify:'',
            direction:'',
            condition:''
        })

        // 选择房型
        const selectTag = (title,index) => {
            
            buyHouse.currentIndex = index;
            selectDatum.verify = title;
        }

        // 选择户型
        const roomSelect = (title,index) => {
            buyHouse.roomIndex = index;
            selectDatum.direction = title;
        }

        // 选房条件
        const conditionSelect = (title,index) => {
            buyHouse.conditionIndex = index;
            selectDatum.condition = title;
        }

        // 清空数据
        const cancelDatum = (val) => {
            console.log(val,'val');
            buyHouse.currentIndex = val;
            buyHouse.roomIndex = val;
            buyHouse.conditionIndex = val;
            selectDatum.verify = val;
            selectDatum.direction = val;
            selectDatum.condition = val;
        }

        return {
            buyHouse,
            selectDatum,
            selectTag,
            roomSelect,
            conditionSelect,
            cancelDatum,
            
            
        }
  },
})
</script>

<style lang='less' scoped>
.orientation{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    .orientation_tit{
        width: 100%;
        height: 60px;
    }
    .orientation_houseCont{
        width: 100%;
    }
    .orientation_type{
        flex: 1;
        overflow-y: auto;
        padding: 0 30px;
        .verify_type{
            width: 100%;
            height: auto;
            text-align: center;
            margin-top: 30px;
            h3{
                font-size: 17px;
                color: #999999;
            }
            .verify_select_type{
                width: 100%;
                margin: 0 auto;
                height: auto;
                margin-top: 15px;
                display: flex;
                .active{
                    color: #fff;
                    background: #f19e39;
                }
                p:first-child{
                    margin-left: 65px;
                }
                p{
                    width: 86px;
                    height: 30px;
                    margin-right: 12px;
                    color: #999999;
                    font-size: 15px;
                    background: #faf7f8;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
            }
        }

        .buyHouse_orientation{
            width: 100%;
            height: auto;
            text-align: center;
            margin-top: 30px;
            h3{
                font-size: 17px;
                color: #999999;
            }
            .buyHouse_select_orientation{
                width: 100%;
                margin: 0 auto;
                height: auto;
                margin-top: 15px;
                display: flex;
                flex-wrap: wrap;
                justify-content: space-between;
                .roomActive{
                    color: #fff;
                    background: #f19e39;
                }
                p{
                    width: 70px;
                    height: 30px;
                    color: #999999;
                    font-size: 15px;
                    background: #faf7f8;
                    margin-bottom: 10px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
                p:nth-child(4){
                    margin-right: 0;
                }
            }
            
        }

        .buyHouse_condition{
            width: 100%;
            height: auto;
            text-align: center;
            margin-top: 20px;
            h3{
                font-size: 17px;
                color: #999999;
            }
            .buyHouse_select_condition{
                width: 100%;
                margin: 0 auto;
                height: auto;
                margin-top: 15px;
                display: flex;
                flex-wrap: wrap;
                justify-content: space-between;
                .roomActive{
                    color: #fff;
                    background: #f19e39;
                }
                p{
                    width: 70px;
                    height: 30px;
                    color: #999999;
                    font-size: 13px;
                    background: #faf7f8;
                    margin-bottom: 10px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
                p:nth-child(4){
                    margin-right: 0;
                }
            }
            
        }
    }
    
}
</style>
